package com.exporter.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JRadioButton;

public class RadioButtonActionListener implements ActionListener
{
    ButtonGroup radioBtnGroup; 
    JRadioButton radioExportFromDate;
    JRadioButton radioExportFilesOfDate;
    JComboBox comboFileOfDate;
    JComboBox comboExportFromDate;
    JLabel lblUptoDate;
    JComboBox comboToDate;
    public RadioButtonActionListener(ButtonGroup radioBtnGroup, JRadioButton radioExportFromDate, JRadioButton radioExportFilesOfDate, JComboBox comboExportFromDate, JComboBox comboFileOfDate, JLabel lblUptoDate, JComboBox comboToDate)
    {
        this.radioBtnGroup = radioBtnGroup;
        this.radioExportFromDate = radioExportFromDate;
        this.radioExportFilesOfDate = radioExportFilesOfDate;
        this.comboExportFromDate = comboExportFromDate;
        this.comboFileOfDate = comboFileOfDate;
        this.lblUptoDate = lblUptoDate;
        this.comboToDate = comboToDate;
    }
    
    @Override
    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource() == radioExportFromDate)
        {
            comboExportFromDate.setEnabled( true );
            lblUptoDate.setEnabled( true );
            comboToDate.setEnabled( true );
            comboFileOfDate.setEnabled( false );
        }
        else if(ae.getSource() == radioExportFilesOfDate)
        {
            comboFileOfDate.setEnabled( true );
            comboExportFromDate.setEnabled( false );
            lblUptoDate.setEnabled( false );
            comboToDate.setEnabled( false );
        }
    }

}

